'''
  res.text 服务器返回Unicode编码的字符串，经过解码
  res.content 服务器返回的字节流数据bytes，直接拿到网络数据byte
    在网络中传输都是经过编码的byte，
  
'''

import requests

data = {
  'first': 'true',
  'pn': '1',
  'kd': 'python'
}

url = 'https://www.lagou.com/jobs/positionAjax.json?city=%E5%8C%97%E4%BA%AC&needAddtionalResult=false'

headers = {
  'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
  'Referer': 'https://www.lagou.com/jobs/list_python/p-city_2?&cl=false&fromSearch=true&labelWords=&suginput=',
  'Cookie':'user_trace_token=20200917160953-c5932cbc-bad1-4d04-925a-6793ae3ecc8f; _ga=GA1.2.751167182.1600330131; LGUID=20200917160954-975c3509-b2b7-4729-96b2-c98f480413bd; JSESSIONID=ABAAABAABEIABCI8F889FAF4973DACE9915B576EE6D5218; WEBTJ-ID=20200917161024-1749b1d54f235a-0d23f5cf80e664-4e400228-2073600-1749b1d54f3417; RECOMMEND_TIP=true; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1600330131,1600330226; _gid=GA1.2.1581890703.1600330226; index_location_city=%E5%85%A8%E5%9B%BD; TG-TRACK-CODE=index_search; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221749b1d7e113b1-04acd7464808dd-4e400228-2073600-1749b1d7e1245f%22%2C%22%24device_id%22%3A%221749b1d7e113b1-04acd7464808dd-4e400228-2073600-1749b1d7e1245f%22%7D; sajssdk_2015_cross_new_user=1; X_MIDDLE_TOKEN=c46c5e1b6ecd4ba1c901b3546b675a60; X_HTTP_TOKEN=685967af146360a029803300616b4c25cffb6c17fe; LGRID=20200917162133-954bafd6-66c7-4147-8b3d-c6195b4768ed; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1600330829; SEARCH_ID=b54ccca67cfd461290bff307d560fc53',
  'sec-fetch-dest':'empty',
  'sec-fetch-mode':'cors',
  'sec-fetch-site':'same-origin',
  'x-anit-forge-code':'0',
  'x-anit-forge-token': 'None',
  'x-requested-with':'XMLHttpRequest'
}

proxy = {
  'http': '125.108.112.134:9000'
}

res = requests.post(url, data=data, headers=headers, proxies = proxy)

print(res.json()) # 将text数据转换json输出

